<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
<script>
	function isCheck(){
		if($(this).is(':checked')){
			$("#class_id").hide();
		}else{
			$("#class_id").show();
		}
	} 
	 $(document).ready(function() {
   		$('#Classes_is_main').click(isCheck);
 	});
 	
</script>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'classes-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>20,'maxlength'=>20)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'is_main'); ?>
        <?php echo $form->checkBox($model,'is_main',array('value' => '1', 'uncheckValue'=>'0')); ?>
        <?php echo $form->error($model, 'is_main'); ?>
	</div>
	<?php
	if($model->is_main){
		$style = ' style="display:none"';	
	}else{
		$style = '';	
	}
	?>
	<div class="row" id="class_id"<?php echo $style?>>
		<?php echo $form->labelEx($model,'class_id'); 
		$select = array(''=>'Please Select Class'); 
		$data = CHtml::listData($model->getMainClass(),'id','name');
		echo CHtml::activeDropDownList($model,'class_id',$data,array('empty'=>'Please select a class')); 
		echo $form->error($model,'class_id'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'activated'); ?>
		<?php echo $form->checkBox($model,'activated',array('value' => '1', 'uncheckValue'=>'0')); ?>
		<?php echo $form->error($model,'activated'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->